//package com.haibara.aioj.kafka.listener;
//
//import cn.hutool.json.JSONUtil;
//import com.haibara.aioj.constant.KafkaConstant;
//import com.haibara.aioj.judge.model.ExecuteCodeRequest;
//import com.haibara.aioj.judge.model.ExecuteCodeRespond;
//import com.haibara.aioj.judge.service.JudgeService;
//import com.haibara.aioj.kafka.processor.Processor;
//import com.haibara.aioj.model.entity.QuestionSubmit;
//import com.haibara.aioj.model.enums.JudgeResultEnum;
//import com.haibara.aioj.model.enums.QuestionSubmitStatusEnum;
//import com.haibara.aioj.service.QuestionSubmitService;
//import jakarta.annotation.Resource;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.kafka.annotation.KafkaListener;
//import org.springframework.kafka.support.Acknowledgment;
//import org.springframework.retry.support.RetryTemplate;
//import org.springframework.stereotype.Component;
//
//import java.util.List;
//
///**
// * 本地测试沙箱
// *
// * @Author: mengyu
// * @Date: 2025/2/11
// */
//@Component
//@Slf4j
//public class RunCodeListener {
//    @Resource
//    private RetryTemplate kafkaRetryTemplate;
//    @Resource
//    private Processor processor;
//
//    @KafkaListener(topics = KafkaConstant.RUN_CODE_TOPIC, groupId = KafkaConstant.RUN_CODE_GROUP)
//    public void consumerJudgeMessage(String content, Acknowledgment ack) {
//        ExecuteCodeRequest ecr = JSONUtil.toBean(content, ExecuteCodeRequest.class);
//        kafkaRetryTemplate.execute(retryContext -> {
//            // 返回测试数据
//            ExecuteCodeRespond result = ExecuteCodeRespond.builder()
//                    .questionSubmitId(ecr.getQuestionSubmitId())
//                    .timeUsed(0)
//                    .memoryUsed(0)
//                    .resultStatus(ExecuteCodeRespond.SUCCESS)
//                    .outputList(List.of("test1")).build();
//            processor.sendMsg(result);
//            ack.acknowledge();
//            return null;
//        }, retryContext -> {
//            ack.acknowledge();
//            return null;
//        });
//    }
//}
